Claw, dd1 used to do very similar, and still does at times of.stress.
Have you managed to flick through the statement I sent you (dont blame you if you haven't - its mammoth!)
We talk a bit in there about dd1's conversational routines. We always had the feeling that they happened because dd1 didn't know how to join in a conversation, but desperately wanted to, and so would say what she could say, or what she knewhad got her a response before.
At times this would be quoting from books. Eg, if dh and I were talking about something, and said "oh dear!" dd1 would immediately launch into reciting (and expecting us to join in as we did when reading the book with her) Maisy's Pool. This could happen over any word or phrase that featured in that book. Or if we talked about lunch, she would start quoting the Gruffalo, or go into her food conversation routine - "I'd like sooooooome....." said with a huge cheek grin as she knew it wasn't lunch time, but we were talking about food, so why shouldn't she?
Obviously it is very different with your ds, as he has so much more language to use, but the situation does sound similar.
It seems as though has "got" the fact that people talk each other, and that they impart information. But he seems at a loss as to what he is supposed to say, so says something that has wprked for someone else.
Dd1 used to be very flexible with her echolalia too, and use it to suit her purpose. So she would use a learnt phrase that contained most of the right bits of information, trying to think of an example now.... eg "i haven't got any chocolate" actually meant "I've just seen chocolate on the shelf on a shop and I want some but I don't know how to ask for it" not a very good example, but hopefully you see what I mean.
As for stopping it vs going with the flow. Hmmm, a tricky one. We joined in with dd1 when she was little (2-3 ish) as it was the only conversation we could have with her and it was nice to head her talk it did drive.me nuts though, especially when she got stuck on a loop for hours and hours.
I tried to look at it as at least she was learning the joy of interaction, and learning turn taking etc. We slowly tried to change things, so that she didn't get set on exactly the same sequence each time, and to show her that conversations could be different, but again, your ds is starting at a very different point.
We also indulged it because we wanted to reward her efforts - she was, after all, trying her hardest to join in with us, in the only way she knew how (not to say we didn't ignore at times, or get frustrated and cross)