Well, there's some subtlety here.
EDIT: And the subtlety was apparently a little lost in my effort to recommend some sound practices.
Bottom line; if you "hide" your AP at home or at the office, you have to configure your client device(s) to broadcast that SSID. That's because the AP's aren't broadcasting it. Somebody has to broadcast it. If you hide your AP, that somebody becomes your client device. Which means that everywhere you go, if you have your phone or laptop or other wireless device turned on, it is broadcasting your SSID on every WiFi channel, waiting for an AP to say "Here I am."
Here is an example of a normal WiFi client probe request. Note that the SSID field is empty (Length=0):
Image source: https://mrncciew.com/2014/10/27/cwap-802-11-probe-requestresponse/
Here is an example of a normal WiFi access point probe response. Note that it contains an SSID (called "MRN-EAP"). If this SSID is one the client wants to connect to, it can connect:
So, if you want to broadcast your home or office SSID everywhere you go, and give WiFi pineapple-equipped attackers far and wide an additional opportunity to get your wireless device to connect to their rogue access point, hiding your home/office SSID is an effective way to accomplish that.
Otherwise, just give your home/office SSID a sensible name, perhaps one that is meaningful to you without divulging more than you want. Maybe call it "GANDALF" instead of "TheRobertsonsHouse," make sure you're using WPA-2 with a good, long complex key, and rest assured you have done it the right way. ;-)
Back to the original post:
If you have masked your WiFi SSID so that your AP does not broadcast it, then your client device has to broadcast the SSID, like a baby sheep constantly calling for it's mother. It'll do this at your house, at the office, at the coffee shop, at the airport, wherever. In that case, yes, an attacker can absolutely answer that call. Of course, to actually get you connected they would need to know the key (password) for your WiFi network, or if you have your WiFi network unsecured, your device will hook right up to the attacker's rogue access point.
So people will sometimes think that hiding their WiFi SSID is a good security practice, but it is actually just the opposite. It is an anti-practice, a bad idea for security.
What can really get you is somebody using a WiFi pineapple and advertising itself as a common commercial WiFi network, such as AT&T or other systems commonly used in hotels, restaurants, bus terminals, airports, and other locations. The WiFi connection is intentionally unsecured, so that you can connect easily then be redirected to a guest portal where you have to log in. That guest portal is easy to fake. It's just a web page. So you hook right up, "authenticate" to the attacker's fake guest portal with a username and password (which the attacker now has), and then the attacker captures and analyzes all of your network traffic from that point forward, possibly even doing things like automatically redirecting HTTPS connections to the HTTP protocol, and so on.
One of the best defenses against this type of attack is to use a VPN, particularly if you connect from public locations a lot, and never, ever ignore any certificate validation error messages, which could indicate that a man in the middle attacker has intercepted your communication and is substituting a fake server certificate for the real one so that they can decrypt your communication on the fly.