Probably in the right line - you don't need a passport or anything to travel between London and Dublin, and the flights leave from the domestic part of T1. So if you are arriving from the US then I'm not surprised you'd be required to clear immigration in London, and the immigration officer had no way of being sure you would actually continue to Dublin and not just stay in London.
Also, you could have just walked straight out at Dublin (although given your non-EU status, getting your passport stamped was a wise move.)