Mainz and the west bank of the Rhine down river almost to Bonn is located in the German "Land" (state) of Rheinland-Pfalz (Rhineland-Palatinate). So you can use that is called a Laender Ticket for daily travels.
You don't say how big your family is. The Laender Ticket allows your group of up to 5 adults unlimited travel for the entire day from 9 am until 3 am the next day for one price on regional and local trains and buses. Children or grand children of the ticket holder under the age of 15 travel free, and do not count against the maximum of 5 adults. The price is 24 euro for the first person, and 5 euros for each additional adult person.
So to visit Rheinstein castle, you would buy a Rheinland-Pfalz ticket out of a vending machine at the Mainz train station, (or from a manned ticket window with a 2 euro service charge), and ride a Mittelrheinbahn train to the nearest station, Trechtingshausen, and walk to the castle from there, about 30 minutes according to the website.
As an example, if you had 3 adults, (husband, wife, 16 yr old daughter) and 2 children under 15, you would buy a 3-person R-P ticket for 34 euro out of the vending machine. Travel regional trains only, no IC or ICE trains. After the castle, you could also make other journeys the same day to say Koblenz and the lower Mosel River.
Details at: http://www.bahn.com/i/view/USA/en/prices/germany-regional/rhineland-palatinate-ticket.shtml