@Fabiano74 I assume your question means you have self check-in. So the way to avoid this is to have a door lock that you can program the new code for the new guest into only from check-in time onward. So if they arrive 2 hours before the appropriate time, they won't be able to enter.
And you should make guests aware of this in the check in info you send them.