A loan for a house typically isn't really "credit", because the value of the house covers the loan. The small print in your mortgage will say that if you default the bank will get the house.
There is some risk to the bank because the house may have declined in value and it may be tricky to sell it when you default. That's why they do a risk assessment, but it can be a lot less invasive than for providing a personal loan for an education.
Large banks were unwilling to loan $20k to me for a used car, even though I had $60k in cash in the bank and a $70k a year job I had for over 5 years, and no history of debt, because Transunion said I had no credit history.
So instead a local credit union got a free $1500 for servicing that loan. A loan that I explicitly only took to "build credit" ie, pay a bank profit so they would vouch for me, which is what a credit score is designed to show, how much profit you give to banks and credit card companies for financing.
They don't want to loan out money that might be less profitable than a loan to someone who has paid a thousand credit card payments.
The credit union then proceeded to Not report my loan to the credit agencies! meaning I still have no credit. Awesome.
There is some risk to the bank because the house may have declined in value and it may be tricky to sell it when you default. That's why they do a risk assessment, but it can be a lot less invasive than for providing a personal loan for an education.