Yes this can and does happen more than you'd expect. As pp said, typically border line credit has more to worry about that an individual with perfect credit. Although, once the loan gets to underwriting, anything can happen. Many times the denial comes from reasons that have nothing to do with credit. A number of issues about the house and/or property can be reason for denial.
For example, in the last year, I'll give you some reasons why some of my clients were denied for a loan AFTER they received a pre-approval and AFTER they found their dream home and AFTER they put in their offer, had inspections and started packing...
House sits in flood zone, septic system not up to code, got a new credit card and charged $500, property used well water when public water was available, chipping/peeling paint on house, foundation cracked and on and on and on....
Please keep in mind, each situation is different and each buyer, seller and property will be completely different transactions. Just keep in contact with your lender and real estate agent. They will (should) keep you notified of any guideline changes that may affect your purchase. Good luck!