Well, for one thing, NONE of the elves were at Helm's Deep in the books. Peter Jackson made that one up.
As for why none fought with Aragorn in the Gondor theater of war, there are 3 reasons:
Population.
There weren't all THAT many Elves left in Middle-earth by the time of the War of the RingThere weren't all THAT many Elves left in Middle-earth by the time of the War of the Ring - most had already left Middle-earth to sail into the West. There also weren't all that many Dwarves - a lot of them had been killed in Moria, and Erebor was JUST being repopulated from a complete zero at the time of Smaug and The Hobbit.
They actually DID participate in the war, just not in the Gondor theater.
Dwarves had their own problems at the moment to deal with - those of Erebor / the Lonely Mountain along with the men of Dale were besieged by Easterlings to the north.
This was actually by "design" of Gandalf, with the aim of splitting up Sauron's forces:
So it was that when the War came at last the main assault was turned southwards; yet even so with his far-stretched right hand Sauron might have done great evil in the North, if King Dáin and King Brand had not stood in his path.
... (this all from Appendices in Return of the King):
'I grieved at the fall of Thorin,' said Gandalf; 'and now we hear that Dáin has fallen, fighting in Dale again, even while we fought here. I should call that a heavy loss, if it was not a wonder rather that in his great age he could still wield his axe as mightily as they say that he did, standing over the body of King Brand before the Gate of Erebor until the darkness fell.
'Yet things might have gone far otherwise and far worse. When you think of the great Battle of the Pelennor, do not forget the battles in Dale and the valour of Durin's Folk. Think of what might have been. Dragon-fire and savage swords in Eriador, night in Rivendell. There might be no Queen in Gondor. We might now hope to return from the victory here only to ruin and ash. But that has been averted - because I met Thorin Oakenshield one evening on the edge of spring in Bree. A chance-meeting, as we say in Middle-earth.'
Elves of Mirkwood and Lórien came under attack by forces from Dol Guldur at the same time
Geography.
Elves and Dwarves lived fairly far from Gondor. IIRC at least 500-600 miles for most part but I'll dig deeper. Even had they been free from fighting AND numerous, they wouldn't have gotten there on time.