Or one has to go to a counter? I would expect some extra fee at the counter.
Ticket machines (for trains) are not very common in Poland, you'd rather buy one at the counter. However, it is also possible that the counter will be closed (depending on how big the station is and what time of day it is) - in that case you can buy a ticket aboard from the train conductor, you should do this as soon as you get into the train, he should be available in the first compartment of the train, if not - wait for him.
The only extra fee will be charged when you buy the ticket at the train while counter at the station was open. Nonetheless ticket price will be the same at the counter and in the machine.