Decomposing a matrix as a sum of two bitstrings
First thing I notice is that you initialize your lists to contain strings

array1 = [""] * len(M)
array2 = [""] * len(M)


but later assign integer values to these. This is misleading, and so I would instead do

array1 = [0] * len(M)
array2 = [0] * len(M)


This has the added benefit that we get one case for free- if we want the value to be zeros (value == 0) we don't have to do anything. 

Another issue I see with these variables is that they are named arrayX, but are in fact lists. In general, its best to leave out the type in the variable name, and just provide a descriptive name for its purpose. I would name these something like bitsA and bitsB, which also follows suite in A/B vs 1/2 naming.

Moving into your for loop, I would first reorder these conditionals to check value in numerical order (zero case first, then one, etc.), however as mentioned before we can now skip case zero, and so with only two cases (one or two) its not as big of a deal in my opinion. There is still one problem though. In one conditional you check A&gt;B and then in the other you check the exact opposite. This added redundancy is unnecessary, and if you later edit one to be A&lt;B, neither case will cover A==B. For this reason, it should be removed.

Normally I argue for reducing nested if statements, but in this case it seems like a logical separation, since the two subcases for value == 1 really mirror each other and deserve distinguishing from the value == 2 case. I would rewrite the loop as:

for index, value in enumerate(M):
    if value == 2:
        array1[index] = 1
        array2[index] = 1
        A -= 1
        B -= 1

    elif value == 1:
        if A &gt; B:
            array1[index] = 1
            array2[index] = 0
            A -= 1
        else:
            array1[index] = 0
            array2[index] = 1
            B -= 1


However, there is one other route we could take, which would remove the remaining repeated logic.

for index, value in enumerate(M):
    if value == 2 or value == 1 and A &gt; B:
        array1[index] = 1
        A -= 1
    if value == 2 or value == 1 and A &lt;= B:
        array2[index] = 1
        B -= 1


Note this does break that rule I just mentioned about not including both A &gt; B and A &lt;= B, because our if statements are independent- both can execute. It becomes a trade off of bug resistance vs reducing redundancy.