Baby pooping solid help!

A

So my son (four months) started pooping solid formed poops since before I started him on solids. The doctor recommended starting fruits first when I do or give him a little bit of applejuice or water and that’s what I did and his poops got softer. Now he’s started pooping solid again and I’m not sure what it is. I haven’t changed his formula he is on similac advanced but I also breast feed. Mabey it’s something in my breastmilk? I drink dairy so Mabey it’s a reaction to that?? Any mommas have the same experience and how did you resolve it? I just don’t want my LO to be in pain.