No matter what variables you use, the idea remains the same: with functions, you take your input - here a, and apply something to it - 2a + 2. Here, your input is a². We put a² in for a. It might look strange at first - you put a variable in, not a number, but anything can go in a function and come out on the other side of the equals sign. The function does the same thing(s) as before.
P(a) = 2a + 2
P(a²) = 2a² +2
Notice how the a and a-squared pieces match up but the numbers and + stay the same.
Thus, P(a²) = 2a² +2