Since 2022 it is no longer possible to buy tickets on German trains:
Wer ohne Papier- oder Onlineticket in einen Zug steigt, muss richtig tief in die Tasche greifen. Laut Gesetz wird der doppelte Fahrpreis fällig, mindestens allerdings 60 Euro.
Someone entering a train without a paper or online ticket, must dig deeply in the pockets. According to the law, the double ticket price will be applied, and at least 60 Euro.
On 2022-01-01 I entered the train at the station Rückersbacher Schlucht:
This station has no ticket machine (and certainly no ticket office). It also has no wifi.
Finally I got on the train and used the train wifi to buy a ticket online, which worked because I had a smartphone on me. But even that would seem to violate the rule that one must buy a ticket before entering the train. How can I buy a ticket for this train if I do not have internet connectivity at the departure station? Signs on the train itself also reminded passengers that they have to buy the ticket before entering the train or risking a fine of at least €60.