It's not really a case of "just the coffee" - it depends a lot on how you normally tolerate caffeine and your personal sensitivity. The reaction you had was real and uncomfortable, but the fact that it normalized within a few hours is a good sign. Caffeine really does mess with your heart rhythm, but there are people who can drink three cups without much impact and others who get palpitations from just one.
What maybe wasn't mentioned: that feeling of fear you experienced - that conviction that something serious was happening - it makes the tachycardia worse. Anxiety creates a cycle: your heart beats faster, you get scared, that speeds it up even more, and it feels like it'll never stop. When the caffeine leaves your body, the panic also decreases, and everything goes back to normal.
For next time, start with less coffee and space it out over time, don't drink it all at once. If this happens again with smaller doses, or if you notice the tachycardia takes longer to pass, then it'd be good to get a routine check-up. But an isolated episode from excessive caffeine isn't concerning.