OSX keeps a list of wifi networks you have previously joined. If you find that your computer keeps joining the wrong wifi, you can fix it this way.
A common issue with joining the wrong wifi will frequently have to do with Starbucks or cable hotspots (TWCWifi, CableWifi, etc.)
On your Mac, go to System Preferences, Network. If “Wi-Fi” is not already highlighted, then click on it. Then click on “Advanced”.
On the next screen, you will see a list of every wifi you have ever joined. Initially, this list may be very long, but ideally, this list is very short.
Click the minus “-” sign on any wifi network that you do not need to automatically join in the future.
OSX will join wifi networks on this list in the order that they are listed, so if you wish to change the priority order of this list, you can reorder this list by dragging the lines upward or downward.