It’s all simpler than what you think (just like Trump.)
Obama (a man Trump HATES/ENVIES/COMPETES WITH) told him NOT to do something, therefore, Trump HAD to DO IT.
His Malignant Narcissism left him no other choice but to do the opposite of what Obama told him. His EGO would not let him do anything less but to oppose Obama in all things, to prove Trump was the better man (in his own mind.)