You said “I don’t understand why this happens.” I answered that. If you
read my answer, and run the code I suggested you run, you should
understand why it happens.
I then gave you not one but two solutions for how to fix it. All you
needed to do was change the calls to print() to do whatever you wanted
to do instead.
You are trying to index lists with a list instead of an integer.
m = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
m # returns [1, 2, 3]
m[[1, 2, 3]] # raises an error.
When you iterate over m in a for-loop, the loop doesn’t give you the
indices 0, 1, 3. It gives you the elements of m, namely:
[1, 2, 3]
as the first element, then [4, 5, 6], then [7, 8, 9].
As a beginner, you will learn a million times more by actually
experimenting with code, and printing the values so you can see what
they are, then by having us just hand you a chunk of code that you copy
and paste and have no idea how or why it works.
As a beginner, your best friend in the world is print()