It is modestly trivial (most of the time) to rebuild the .src.rpm for common auxiliary apps like squid. Grab a 4.x test box, install the devel tools, build the .src.rpm from 5.x and test. There may be a repo that has done the work for you. A quick google'n will help. Something like "squid 2.6 el4" or similar.

I don't think your downloaded binary of "squid-2.6.STABLE21-3.el5.i386.rpm" will drop right into your CentOS 4.x install. It may. I've not tried it and would not in this kind of situation. What I suggest is you get the SOURCE rpm for squid-2.6.STABLE21-3.el5.src.rpm and rebuild that onto a 4.7 dev setup. Since this isn't making as much sense as I had hoped to you, you may not be a good candidate to build the source on your own. So, the magic google incantation I tried was "squid-2.6 el4 rpm" and my first link was one click from getting what you likely want ;)
http://rpm.pbone.net/index.php3/stat/4/idpl/12208939/com/squid26-2.6.STABLE22-1.el4.pp.i386.rpm.html

However, I have not attempted this install since I don't have 4.x running squid. Please be aware of possible third party install issues:
http://wiki.centos.org/AdditionalResources/Repositories
Pay attention to the "3rd Party Repositories" section, please.