There are probably endless reasons why you could be denied a mortgage, and likely new ones being realized every day. It’s a funny business, really.
With so much money at stake and so much risk to lenders if they don’t do their diligence, you can bet you’ll be vetted pretty hard.
If anything doesn’t look right, with you or the property, it’s not out of the realm of possibilities to be flat out denied.
Those aforementioned student loans or credit cards can also come back to bite you, either by limiting how much you can borrow or by pushing your credit scores down below acceptable levels.
That doesn’t mean give up, it just means you might have to go back to the drawing board and/or find a new lender willing to work with you. It also highlights the importance of preparation!