Unfortunately there is no way to make "sure" that doesn't happen.i want to make sure i'm not getting "lemon" or a bike that will fall apart on me my first week riding it.
A bike that looks clean and starts good cold and runs good is probably gonna be OK. Having maintenance records is a plus.
Avoid any used bikes where the owner says "It only needs......"
If that is true, you should have DONE it already.
Also avoid one that has a LOT of "cuts and bruises".
A little scrape here and there is not bad but lots of the probably means abuse.