Most of the time, when I search something using the Safari search bar, it gives me results from Google. Sometimes however, it uses the default search engine of my ISP. How can I fix this and what are the reasons it is happening?
Assuming that everything's on the up-and-up with your ISP, this kind of behavior typically is a result of some connection failure between your ISP and Google ("Hmmm, I can't find Google, so I'll route this to our search engine instead.") - and in my experience it's most often due to DNS issues.
One easy way to figure out if it is due to DNS issues is change what DNS servers your network connects to. Two options are Google itself (220.127.116.11 and 18.104.22.168 for IPv4 service or 2001:4860:4860::8888 and 2001:4860:4860::8844 for IPv6) or OpenDNS (22.214.171.124 and 126.96.36.199 for IPv4 or 2620:0:ccc::2 and 2620:0:ccd::2 for IPv6).
Depending on the current DNS servers your computer/network is currently using, you could even see faster lookup performance.