I don't work at Spotify, so I can't give you a completely accurate answer. However, I do have some experience in sorting algorithms and logic so I'll simply state how I think they did it (my playlist turned out pretty well too ^^).
Each song on Spotify most likely has tags beyond the ones visible to us - things such as speed, genre, and other specific attributes of the song are stored with each song. When listening to music, saving songs to your library and making playlists, Spotify most likely keeps track of which genres you lean towards as well as the common tags on your songs (as shown in your Wrapped 2018 summary).
I listen to a lot of Korean hip-hop and R&B - Spotify's algorithm most likely took into consideration that I already have a lot of that type of music, attempted to find songs with similar tags but different genres.