I remember having this problem with a piece of music which I did for my G6 (a modern edition of a baroque piece). There was a B-on-the-middle-line made flat, and later on in the bar a B-above-the-stave. I'd played this piece for ages without realising that I'd played both Bs flat. I actually noticed this in a lesson one day, and said to my teacher "Oh, hang on, should that second B be flat or not?" He then played the phrase through with the flat, and then with the natural. It was
definitely meant to be flat, the natural just sounded awful...
My teacher said many baroque composers would fail their G5 theory if they were to take it today writing as they did in their day

We then got in to further discussion, as this piece was titled as 'in d-minor' but the key signature contained no flats (or sharps!) If you are in a minor flat key, the 'last flat' on the key signature is the sixth note of the scale - so it would often be sharpened (as in your melodic minor ascending scale). So it was quite common in the baroque era to just leave that last flat out of the key signature (in minor flat keys), and instead just pop in the accidental flats when you didn't want it to be the sharpened-sixth-back-to-natural.
Of course, then we go on to facsimiles created before the natural sign was invented, where the sharp sign means 'raise a semitone' and the flat sign means 'lower a semitone', rather than distinctly meaning the sharp or flat note name

So in a piece with Bb in the key signature, a # before a B would mean a B natural, not a B sharp. Most of the time

At least for AB theory exams, the AB theory books are explicit about what they mean - so you can give a definitive answer in those cases