In general, a good practice is to figure out what key your song (or part of your song) is in, and then whenever you need an accidental, use the one that belongs to that key.
For example, the key of B♭ major contains the following notes: B♭, C, D, E♭, F, G, A, B♭. If you had written your score using notes from B♭ major, this problem wouldn't have happened.
There is no key that contains both G and A♯, and that's a good indication that you usually don't want to use the notes G and A♯ nearby each other. That partly explains why this problem happened in the first place: you provided unusual input, so you got unusual output.
(Of course, you should usually use a key signature, and that will make your scores easier to read by eliminating most of the accidentals. If I remember correctly, Lilypond still makes you type the accidentals even if you have a key signature, and so it's still important—but also easy—to know what key you're in and stick mainly to notes from that key.)