It's probably possible to cram in both castles into one day, but you'll probably need to leave very early and arrive very late in Cologne, which in many ways is just another standard big city, so it makes much more sense to me that you would stay either in St. Goar (home of Rheinfels - the most scenic spot on the Rhine, IMO) or in Braubach (home of Marksburg - a very attractive old-world village.)
You are still planning to travel by TRAIN, right? I'd look at the DB schedule and plan on getting to St. Goar as early as you're comfortable leaving and with at least a 3-hour stopover there. See the castle and town and have a nice meal (the TI office will hold your bags.) Then ferry across to St. Goarshausen and catch a train (22 minutes) north to Braubach for the night. See Marksburg in the morning.
Braubach lodging options: http://braubach.welterbe-mittelrhein.de/en/gastronomy/lodging/