It's the autoplay option.
"Autoplay takes the work out of choosing what to play next. Just play a song, then Autoplay finds similar songs and plays them afterward."
Learn how to add music to a queue to play next in the Apple Music app.
support.apple.com