This happens if you use a bad mod. A stable Freecam should lock your body in place ( MotionX=0 , MotionY=0 ). Try switching to Lunar Client, which has the most stable implementation.
Some servers use "Movement Packets" checks. If your camera attempts to send movement packets while your body is stationary, advanced anti-cheats flag you. This is why the clients listed above (Lunar/Badlion) are "safe"—they suppress these packets. freecam mod 1.8.9