Mathematica quietly, perhaps without you even realizing it, keeps a hidden copy of all the past assignments you might have made since you opened Mathematica this latest time.
That means it doesn't have to take the time to recalculate something that you already did.
That also means, if you didn't realize this was happening, that you can get puzzling results. I'm guessing you might have previously assigned something to a
and or p
Try restarting Mathematica and enter just
Integrate[1/(1-a * cos(p)),{p,0,2*pi}]
and see if the error goes away
If you want to tell it that a^2<1 for this integral then
Integrate[1/(1-a * Cos[p]),{p,0,2*Pi},Assumptions->a^2<1]
will do that