Why my code isn't working?
From Arduino reference: random
In short:

Syntax
random(max)
random(min, max)
Parameters
min: lower bound of the random value, inclusive (optional).
max: upper bound of the random value, exclusive.
Returns
A random number between min and max-1. Data type: long.

Basically your first random returns values {1,2} and second one is even better {0}