Various drivetrain components' manufacturers develop their groupsets in such a way to allow them to work perfectly within the same groupset, and it's great until you start mix-matching your drivetrain components. Due to differences in cassette widths, gaps between gears and corresponding shifter/rear derailleur indexing, setting up a perfectly operating drivetrain is a difficult one. Add more variables, such as straight/bent derailleur hanger, worn out shifter cable etc., and bicycle transmission setup may turn into a nightmare. Pictures below show differences in cassette widths depending on the group it's designed for. The difference in fractions of a millimeter is what can make your drivetrain unoperational, especially in 2019 when 11 and 12-speed groupsets exist with very narrow spacing between gears. That is, until you will match components, like cassettes, derailleur pulleys which correspond to the groupset you're using.