That decision depends on the lender's assessment of the creditworthiness of the person or entity who is attempting to borrow money. However, yes — in general — a business can get a mortgage just like anything else. Getting a loan (even a mortgage — no difference) is legal; it would not be a problem, legally.