How do scientists know what the earth was like after its formation?
A lot of science is based on models.
We can't know for certain what the early Earth looked like. We can however create computer models of how the Earth was created.
If the models agree with what we know then we have confidence that the model is correct.
There have been a number of theories as to how the Moon was formed. Recently the accepted scientific theory is that the Earth was hit by a Mars sized object and the debris formed the Moon.
We can't be completely certain about the early Earth. We do however have the computer power and algorithms to do simulations which can give insight into the early Earth.