But still, in my opinion, it is better to invest the money in real estate than to take it to the bank given the current interest rates on deposits.
Banks also earn from the necessary credit. So, it almost comes down to the same whether you receive little interest on existing money or pay interest on borrowed capital.
It is more about weighing how secure the capital will still be in the near future. Tangible assets do not lose value as easily as cash deposits, which could be an argument for real estate if prices for real estate had not already risen long ago. Demand for real estate is still high, but that can change again, who knows. And having to sell when prices have fallen again can also mean a loss.
In addition, there are the transaction costs (notary, land register entry, broker, etc.) for the purchase and the later resale. That money is definitely gone then. These costs would also have to be seen in relation to the 4 years the OP might own the property.
In the longer term, I would always recommend buying real estate, but for 4 years temporarily, I would reconsider carefully and do (or have someone do) the calculations again. Especially when newly employed, you also lose the flexibility to accept job offers in other locations. And career progress is rarely made in
one company; usually one has to change the job and residence at some point. But everyone has to weigh that for themselves; we can only provide a few possibly overlooked arguments here.