> I am not sure how to go about backing out of the one that I accepted already.
Almost the same way as you said in this post. Don't mention the panic, do mention that the other offer is personally very interesting to you.
Do this after you have accepted and confirmed the second offer. The earlier you do this the better.
There is of course value in keeping your word once you have accepted something - but for how long would you work at a less interesting position for just that? A few months, a year, 3-5 years? If under a few years, then you aren't actually helping them by accepting and "keeping your word".