Trolley is the US term for what we call a tram - i.e. they are meant to resemble a tram outline. What we call trolley buses, they call trackless trolleys.
The names for these vehicles tended to be local, and usage evolved with time too. After all, in Ipswich the locals called their trolley buses trams. In the USA, streetcar become the standard term rather than tram when they were horse- (or cable-)drawn. So with overhead electrification they became electric trolley cars - trolley referring to the pulley on the wire or its housing. In meaning, trolley, bogie, truck, pulley, and lots of other words all overlap to mean "smallish wheel or thing with wheels".
In New York and other cities the name was shortened to trolley-car, and no ambiguity arises if there are no trolley buses. It's a bit ironic that the name is now generally being applied over there to diesel buses that look a bit old fashioned, and with a huge stretch of the imagination look a little bit like a streetcar. But in a city that had streetcars until the 1950s, and called them trolleys, that name is likely to be adapted label new things - even if it makes no sense to outsiders.