My understanding is almost always yes if you can afford it and want to own a house. If the prices go down, you can refinance and pay less. If the prices go up, you’ve already bought the house so it’s just free money.
If you have a good emergency fund layoffs can be managed.