Rails, buildings and train stations are in separate company (DB InfraGO), owned by DB.
But DB has no monopoly on trains in Germany, any company can run trains there.