Cakey foundation

My foundation is always cakey. I’m moisturising my skin and I’m using primer and letting my face dry, then I apply it with a beauty blender. I don’t know what I’m doing wrong so please tell me? Can it be like that because I have acne/ dry skin and scars???