I bought Minecraft on my phone a long time ago. Is it somehow possible that I can transfer this account to the PC? Or do I have to buy Minecraft on the PC first?
No. This is not possible. You would have to buy Minecraft separately for the PC.
You can play the Bedrock Edition on your PC if you (if you have an Android mobile phone) download Bluestacks or Nox and log into the Play Store with your Google account. There are also emulators for iOs. However, as far as I know, these cost money.
However, you can't play the Java Edition if you have bought the Bedrock Edition on your mobile phone.