Depending on your county and their rules you may or may not have time to get a mortgage. My county wants to close in 30 days but with mortgages taking longer these days you need cash to buy at a sheriff's sale.
You can get an inspector to check out the property before the sale if it is occupied or listed with a Realtor and you can get permission and access to the property. You will also have to pay for the inspection at the time it is done.
It is possible to but the property from the owner prior to sale but it isn't very likely to happen. The reason is that most times the value of the property and the balance owed in nearly the same so if you are looking for a deal you will be wanting to do a short sale. But do not let the name fool you. Short sales can take up to 6 months from start to finish.
Sheriff's sale are open to the public.
Sheriff's sales are usually the last straw for the lender. Lenders have exhausted every other avenue to try to bring the owners current without success and are now looking to try to get as much as they can in order to satisfy the loan. They are usually looking for about 80% of the loan balance. If the bids don't go that high the bank will keep the property and finish the foreclosure and list it with a Realtor when the foreclosure is finished.
Hope this helps.