You have a Nikon D3500, and I assume, the 'kit' 18-55... in which case, it 'should' have a switch on the side marked 'A' for Auto-Focus and 'M' for manual focus.....
I 'Did' think to take a photo of mine... but then the conundrum of trying to take a photo of a camera, with that same camera, confounded me, and I thunked to resort to the brochure pics on line, which weren't tenably helpful... and I don't know... What 'seems' to ship with the D3500 isn't quite like my lens, but it has buttons... but what they do? I dont know. If you say it has no AF toggle and you 'have' to do it from the camera menu, I guess we have to take it at that... sounds odd though.
Hyper-Focal Distance! Oh-Kay..... Right, well, you know that the Aperture controls the Depth-of-Field... or how far infront and behind your focus point that 'acceptable' focus extends.
The DoF extends typically 1/3 infront of the point of focus, and 2/3 behind the point of focus. Meanwhile, the extent of the DoF depends on BOTH the aperture set, and the focus range. The smaller the aperture (higher the f-no) the larger the DoF will be; but it's a % of the focus range; so the closer the subject you focus on, so the shorter the DoF becomes for any given aperture setting.
NOW, you have a lens, that has a closest focus distance, and a range of 'critical' focus beyond that,until you reach infinity focus, beyond which anything, at any range, will be in acceptable focus. But, before you reach infinity, you have the DoF zone, where you have some of the Critical-Focus-Zone tagged on the front, which is also in 'acceptable focus'.
So, the Hyper-focal distance, is that at which the DoF zone touches or overlaps the infinity zone, and the whole scene beyond the Hyper-Focal range, is rendered in acceptable focus.... it's not 'quite' infinity focus, but, that plus however much infront of infinity focus you can stretch with the set aperture.
Make sense?
Oh-Kay...
The Critical-Focus-Range.. the range infront of the camera, where the lens has to be focused. So, the bit between the closest focus distance, before which nothing will be rendered in focus, and Infinity Focus, where everything will be.
The longer the focal length of the lens, so the closest focus distance tends to be further from the camera, a-n-d the range of critical focus from there to infinity (or Hyper-Focal) tends to be longer... and the converse applies. Shorter the focal length of the lens, so the closest focus distance tends to be so much closer to the camera, and the critical-focus zone, shorter.
This principle has been applied by camera makers for aeons, to push ever smaller format cameras; because the smaller format camera begs a shorter focal length lens, to give the same angle-of-view, and that shorter lens, consequently shortens the range of Critical Focus.... and in the extreme; you can make a camera effectively Focus Free, and not need any kind of focus mechanism; the lens having such a short focal length, and consequently such a near closest focus distance, and short range of critical focus, that to all practical purposes, you don't need a focus mechanism... nothing that 'matters' is ever going to be so close to the lens as to be rendered out-of-focus. If they also limit the maximum aperture to extend the DoF region, its all 'win' and the camera can be that much cheaper to make, and that much more numpty freindly for the consumer.
But.. step up to enthusiast cameras... exploiting this range of focus, to 'selectively' render subjects in focus against a typically out of focus back-ground, it becomes important, and buyers expect to get these Selective-Focus effect, which denies the camera maker cheaping out on a focus mechanism... until numpty consumers start grumbling, and demand an camera that has this critical focus mechanism... but want a computer to do the twiddling for them!... hey-ho, this is the on-demand push-button modern world for you! Howebler!
IF you know what the Auto-Focus system is playing at, or any critical-focus system, for that matter, you can start to exploit it. And a key in that is to recognise this idea of 'Selective-Focus' and exploiting the DoF zone to your advantage.
Consider the expense many go to hunting out and buying ever 'faster' low f-no lenses, in order to get shallow focus effects, and chuck back-grounds Out-of-Focus.... BUT, if you are a bit 'savvy', you dont actually need such a fast f-number lens, what you are trying to do, isn't create a very shallow DoF around your subject, what you are trying to do is 'just' get your subject 'in' the DoF, but your back-ground 'out' of it!
Now, the AF system, is trying to figure out what 'it' thinks you want in focus... not necessarily what you want out of focus... SO, you point camera at a subject; the electrickery, looks at the pixels and looks specifically for'edges' or discontinuities in the picture, from which it calculates the 'range' to.
If you were doing it manually with an old fashioned manual focus SLR, you would naturally do much the same; you'd look through the viewfinder, adjust the focus until it started getting sharper, go a bit further until you started to loose it, and then come back to where you 'see' best focus. You would be 'focus hunting', and the electickery does exactly the same thing, hunting through the range to to best focus, a bit beyond, and then back again...it just does it very quickly.... or at least it tries to.... if its dark and or the subject lacks contrast to make it hard to tell if the focus is crisp, then it will tend to 'hunt' rather harder, and range rather further... locking the shutter out whilst it hunts.... which is what you described.
But! Selective focus; Idea is to deliberately NOT focus on your subject. This makes it even more difficult for an AF system looking for something it can identify as a subject.... Back to that nice OoFed back-ground idea, and the shallow focus gained from typically lower f-no lenses.
Remember, what you are aiming for is the subject 'in' focus, the back-ground 'out' of focus. Now,,, you dont necessarily need a low f-no lens to create a very shallow DoF around your subject; ALL you need to do, is arrange the DoF zone so that your subject is 'in' it, and the back-ground isn't! And you can do that with an enormous DoF from a pretty tight aperture or high F-No. ALL you need to do, is focus in front of your subject, so that the DoF zone covers what you want 'in' focus, and not what you want 'out' of it.
Now, conventionally, the DoF zone extends 1/3 ahead of your set focal range, and 2/3 behind it. So, lets say, you have a Camera-to-Subject range of 10m, and a DoF zone around that of 2m... you focus dead on the subject, you get 66cm of DoF infront of the subject, and 134cm cm of DoF behind them.
What if they are standing a foot from a wall, you would 'like' to be OoF? Well... that wall is going to be 'in- the DoF zone, it's going to be 'in' focus, isn't it?. B-U-T and this is the difference between Shallow Focus and Selective Focus.
To exploit shallow focus, you would open up the aperture, and shrink the DoF zone... but the camera to subject to back-ground distances are still the same; and you may have to get a very large aperture lens, to shrink that DoF enough that the wall behind is OoF and even then, it may not be all 'that' oof.
On the other hand; if you were to use Selective Focus; what you do, if focus in-front of the subject. That shortens the Focus Distance, which consequently also shortens the DoF; Remember, the DoF is a % of the Focus Distance, 'as if' you had chosen a wider aperture, but without actually doing so.
Now that DoF is still split approximately 1/3 in-front of the Focus Distance, 2/3 behind; so by pulling your Focus forwards what you have done, by focusing on essentially fresh air, that red-dots have a hard time finding.... is pull the whole DoF zone forwards, and now, the back end where the focus drops out is just behind your subject, and the wall is OoFed... but your subject remains in 'acceptable' focus... the 'spare' DoF infront of them, is still there, and there's a bit more of it... but who cares, there's nothing in that bit of the scene to either be in or out of focus... its fresh air!
A-ND, now with this little nugget, you can get those wonderful effects with the subject in-focus and the back-ground not... and do it without such fast aperture lens, and probably better, because you are putting the DoF exactly where you want it in the scene, and not having a split-prism or red-dot tell you where you should focus, and plonking the DoF arbitrarily where it 'thinks' it aught to be around that, leaving ears and noses OoFed....
NOT really what you were asking about, I know; but, turn that on its head, and you get the ideas behind Hyper-Focus, where usually rather than trying to OoF a back-ground behind your subject, you are trying to maximise the DoF, and get as much in focus in-front of a far horizon as you can.
Its the same deal, NOT focusing on the obvious 'subject' but utilising the DoF you get at any aperture, and focusing to get that DoF covering what you want in your picture, from the scene you see.
A-N-D its something that Auto-Focus systems are not particularly good at; because they rely on finding 'something' to plonk a red-dot on, to get a focus range, and free-space don't really give them anything.
But back to your issue; the AF system is trying to find an edge,to get a red dot on to get a range from so it can set the focus.
And in low light, its not very good at it. A lot of AF cameras have a small spot-light next to the lens, for 'AF Assist' in low light. actually chucks a load of light at the scene to try and cut through low contrast so the AF system can 'see' something to plonk a dot on. Pr4oblem is, that this only really works at relatively short ranges, where the AF assist light can actually chuck a spot-light on 'something'. Tends to work OK in a dimly lit room or the like... but, out-doors and at further ranges, rather like trying to light up a sky-scraper a mile away with the little LED on a key-ring!
B-U-T... if you are out-doors and working at those sort of ranges, so you NEED the Auto-Focus to get a target lock on anything?
Its a bit of a skew application of the Selective Focus principle; B-U-T the principles still apply. IF your AF system is struggling, because it cant 'see' in the dark... does it need to? Heck, does it actually need to 'see' in the light?!
In days of yore, not only did cameras not usually have an Auto-Focus mechamism, they seldom had a 'What-you-See, is What-You-Get' through-taking lens view-finder.
I have a wonderful example sat next to the PC here of such a camera, my Uncle's old Ziess Ikonta 'Folder'. Not only does it not have an SLR pentaprism and peep-hole view-finder, it doesn't even have a viewfinder! What it has, is a 'wire frame' gun-sight. You flip up a little metal tab on the end of the lens, and a wire frame on the film door. You look down the lens, through the peep hole, to frame your scene, and level that up with the wire frame to check the edges.... so how do you focus?
Well... when you pop the lens out the front on it's bellows, its latched to the draw at the 'Hyper-Focal' range; if you want to focus more critically than that, there's a little lever against a scale, that moves the lens forwards or back-wards in relation to the film... ah, yes!
But how do you know what's in focus? Well, you probably don't! You have to know how far away your subject is. Which means either guessing rather well, or flaking out a tape measure, or using a little gadget known as a 'range-finder' that uses trigonometry to get one subject super-imposed through two lenses at different angles, so that it can be worked out by maths. And THEN you have to workout what DoF you have got, and whether that's enough to get your subject in focus,or give you enough tolerence around it for any error.
Its all rather laborious... B-U-T it works. A-N-D in practice, you look at your subject, hum and har, guess that its about five cars lenghs or the length of a soccer pitch away, about 100m, and that is what you set on the lens scale as your focus range. You then hum and har a bit more, over how close your guess was, and look at the scale on the lens, or a table from the camera pouch to workout what the DoF you have around that at any apperture... and add a stop 'just in case'.....
And THIS is Selective Focus..... or exploiting the DoF to get what you want in focus,in focus and what you dont, out of focus.......
And to the togs of old, it was second nature,it was just how they HAD to do it..... no electrickery required...... and guess what.... we still CAN and it STILL works!
IF you undertand the principles in play/
If you know what the electrikery is up to, then you don't actually need even SEE to take a photo; you can set it up entirely by the numbers. Modern Electric-Picture-Makers dont always make it all that easy for us, though; they give us lots and lots of numbers we dont really need or want; many electric lenses, especially 'kit' lenses not even having a focus scale on them, let alone a DoF bracket around that.... but... this is 'progress' I am told.... you dont 'need' all that gufrf, the AF system does it all for you.....
Except when it doesn't... as you have just found out about! THEN, then the numbers and scales can be rather very helpful!
Which is probably of little or no help to you, other than, the electric easement in modern electric cameras is very very sophisticated, and very very good.... but it ISN'T infallible, and technology is not really a substitute for good old fashioned know-how!
And knowing how, and how you MIGHT focus... IS pretty fundamental know-how to the job of taking a photo; and AF systems, have in so many ways not actually made it all that much 'easier' but when they run into the margins, harder if not impossible.
But... you thunked to 'Go-Manual' to get round the lock-out... which was right; only you went manual exposure, not manual focus. If you had switched to manual focus, you might have been able to see a clear enough image through the view-finder to asses acceptable focus; possbly even easier still on the back-screen with the image amplified a bit by the electronics.... and at a reasonable focus range and moderate enough aperture, that likely could have been 'good enough'... and not had you locked out by the electrickery, or needing to get more scientific working to the numbers on the scales you dont have on the lens!
Clear as mud?