Buying Länder Tickets from a ticket machine: This is something you will probably have to do as many stations (Bacharach, St. Goar and Oberwesel, for example) have ONLY ticket machines.
There's no advance-purchase price advantage, and tickets don't sell out, so buying them just before you travel is fine. That said, you may want to buy them the day before (for the next day's date of course) if you happen to be at a station and there's a ticket machine available. There is sometimes a line-up at ticket machines too, and if you aren't familiar with the purchase process, you may feel rushed.
Länder tickets have an after-9-a.m. travel restriction. You must not use the high-speed trains (ICE, IC, EC, etc.) RE, RB, MRB, VIA (and a whole lot of other train designations) are fine.
The Rheinland-Pfalz ticket day pass is valid on the St. Goar - St. Goarshausen ferry crossing as well; this is NOT the KD cruise boat - here's a photo of the ferry. This ferry is most handy if you are staying in St. Goar and want to tour Marksburg Castle in Braubach - also good for a day trip to Rüdesheim.
Länder tickets (for statewide travel) are not the only day pass option. Local transit authorities (which are normally smaller than a "Land" or state) also offer day passes for less money. On your Rhine/Mosel visit, you might on some days use the VRM transit authority's "minigroup ticket." It's for 2-5 people, costs just €21.80/day (vs. €28/day with the Rheinland-Pfalz ticket) and is valid for train and bus travel as well - the ferry above is covered too. The mini-group ticket covers rail travel for the Bullay-Cochem-Koblenz-St. Goar-Oberwesel part of your trip (but not Trier-Bullay or Oberwesel-Bacharach.)
Note that the VRM minigroup ticket is available in a 3-day version as well for €43.60.
Sometimes you'll find it's cheaper NOT to buy a day pass. For example, let's say you're staying in Cochem and using the train to reach Moselkern for the walk to Burg Eltz; that train trip is only €4.65 each way with normal tickets, so €18.60 total for two round trip. Oberwesel-Bacharach costs only €2.50 one way. Normal tickets can be bought at ticket machines too, of course.
And sometimes you can ride for free. Staying in/near Cochem? In the Cochem-Zell district, guests who stay with participating innkeepers receive a "Gästeticket" or guest ticket at no charge. The ticket permits free train and bus travel (and discounts on some attractions) within the district during your stay - this would include the trip to Moselkern. THIS PAGE written by one of those innkeepers explains the program . You may want to look for innkeepers like this one who advertise the Gästeticket.