Post a video. There are a few possible reasons, so it's hard to guess without seeing it. Some things to consider:
* You need to very consciously and deliberately keep your knees out. It's hard to focus when a heavy weight is pressing down on you, but you need to stick with it and make a very strong mental effort to keep those knees out.
* Many people who have their knees cave in are trying to drive their chest up or unbend their knees. This is the wrong mental cue and puts all the work on the quads. The proper mental cue is to drive out of the bottom of the squat by driving your ass
straight up. Not forward, but UP, as if there was a chain attached to your tail bone and connected straight up to the ceiling. This engages the glutes, hamstrings and adductors and is a much safer & more efficient squat. Check out
this video.
* Are you able to keep your knees out when you do air squats? If not, you'll need to start doing lots of those while working on your adductor flexibility (do the squat stretch and goblet squats 2-3 times per day).
* Make sure your feet are pointed out and your knees don't slide too far forward.