The Chassam Sofer seen here s.v. על רגל אחד says that Shammai besides being a Talmid Chacham was also a builder by trade, כי הוא היה תלמיד חכם וגם בנאי באמת הבנין.
The apikores thought that a person must choose between being a good person who interacts with other people kindly, or one can dedicate their life to Hashem as a religious recluse. Shammai wanted to show him that it is actually possible to serve Hashem in both regards, and proved this by chasing him with the tool of his trade and allowing the apikores to recognize he was both a talmid chacham and a builder (i.e. involved in a trade and interacting kindly with people).
Hillel's response was to say that you can 'learn on one foot', by which he meant to only involve yourself in kindness. However explains the Chassam Soffer, don't forget that the single foot of kindness includes kindness to Hashem, which means keeping His torah.
The Ben Yehoyada (in one explanation here), similarly, says he was a building-measurer by trade, and so carried a stick with him.