As the picture shows, this is the normal homing situation for Z-axis, where the switch of the Z-homing has a little gap between the metal sheet and the plastic.
However, when homing the Z axis, the metal sheet might have a chance been pushed totally and the gap will disappear. This height change will break the bed level.
I have tested with SD card only and there still have a chance for having different homing position (a little chance though).
What did you already try to solve it?
Disconnect the USB cable and print through the SD card.
But there's still possibility to trigger this situation.
Have you tried running in safe mode?
No, because this situation is not 100% reproducible (I estimate it is about 35% but never precisely count it).
Are you sure this isn't just a hardware issue? Cheap or dying endstops can trigger in different places due to electrical noise etc. I can't remember the specifics of what influences an endstop's accuracy but it definitely can be an issue.
This machine is very new (I just got it from the official retailer 2 weeks ago), and I don't think it is a hardware issue. But of course, there will be a chance that it really is a hardware issue.
As I could remember, this situation did appear after I flashed Marlin 22.214.171.124 firmware. But I have only used the pre-installed official firmware for just a day or two, so I cannot assure if the official firmware is OK.
I have flashed back to the official Creality firmware and will continue monitoring the Z-axis situation.
Hope this could help to identify the real cause, the hardware, or the firmware (or maybe both).
In that case, there may be some settings that the manufacturer put into the firmware to try and eliminate some noise. Creality is regularly corner-cutting like this...
This may not be your solution, but it might be something that you could tune. You might find more help tuning these settings somewhere like the Marlin discord server, where they will be able to tell you exactly what these settings do - where I just kinda guess
I recently spent several days about ready to pull what little hair I have left out trying to resolve this exact same issue on my Ender 3 v2.
I ended up replacing the z endstop switch and now when the z axis is homed it is very consistent again.
In my case I noticed that the position that the end stop triggered was so inconsistent that some times I could hear the switch make a clear 'click' when it triggered and other times I couldn't. The difference between it making the click and not was nearly 1mm! Similar to you, I noticed the switch itself was triggering at different heights, and it wasn't consistent when it would happen.
You may want to try swapping one of the other endstop switches for the Z switch and see if that makes a difference. Both x and y require taking a cover off to access, but the Y switch would probably be the easiest.
If that works, I'd recommend replacing the flaky one. If that doesn't work, you may be having issues with noise, like others have suggested.
I found more information here. I have ordered some end-stops which have capacitors soldered on the PCB.
Ironically, the official end-stop has left empty the position, which was designed for a 100nF capacitor. So I have to order the end-stops from 3rd party and hope they are compatible. Those chip Capacitors are definitely not expensive. In mass purchasing, the price is less than RMB¥0.1 each in China (less than USD$ 0.02), considering where the Creality makes their machines. So each machine will cost no more than RMB ¥1 (less than USD$ 0.2) to add 6 capacitors on the three end-stops and corresponding motherboard sockets.