!= means "not equals to"
So, evidently the old state of the switch was saved in PreviousOnOffSwitchState, and now it's looking to see if the current state, onOffSwitchState, differs from that.
If it does differ, then we look to see in what direction. (Since a change could be high to low or low to high, and knowing merely that it's changed is often not enough.)
So the next if, which you will see is inside the first if, so we know it's changed, looks to see if the current state is high, where presumably a high means pressed. If it IS high, then change the value of the motorEnabled value to its opposite. (! means "not", or opposite)
Boils down to if the button has become pressed, toggle the motor.
Note what I said there: has become pressed, not is pressed. It looks to see first if the switch changed, then to see if it's high. It can only get to the point for looking for the high if it changed, which means it must have been low,ie it's a NEW press. (Else, holding it down wold toggle it forever.)
edit: I know I'm saying what sterretje said, but I had typed it all out while he posted, so thought wth, may as well post too