how can we know for sure you are buying a first mortgag
Get title insurance. That is the only “for sure” solution, and at the moment I’m not aware of any title companies that will insure an auction purchase.
From there it comes down to relative risk. For example a brand new home, with an original first mortgage going to sale is less risky than a home that has been refinanced 5 times over the last 15 years.