Rashi usually starts his commentaries on the book of Bamidbar with the connection between the current and proceeding parsha. For example in Bahalotcha he tells us
Why is the portion dealing with the menorah juxtaposed to the portion dealing with the chieftains? For when Aaron saw the dedication [offerings] of the chieftains, he felt distressed over not joining them in this dedication-neither he nor his tribe. So God said to him, “By your life, yours is greater than theirs, for you will light and prepare the lamps.” .
In the introduction to Shelach he tells us that the spies hadn’t learnt their lesson
Why is the section dealing with the spies juxtaposed with the section dealing with Miriam? Because she was punished over matters of slander, for speaking against her brother, and these wicked people witnessed [it], but did not learn their lesson. .