Because you were doing it from localhost, the connection came from localhost. It has to be exposed out on the internet for it to return an internet IP :)
Anyways, I agree for 1 off things, whatever, use icanhazip or whatever you want, it doesn't matter if you make 1 request a day or 1 request a month... But if you are doing anything in code that uses it, you should just host it yourself and be a good net citizen.