What prevents a bitcoin miner from modifying the code to make mining easier instead of more difficult ?
Nothing (as long as nobody else changes that code as well). I could easily mine hundreds of blocks a second using modified code.
However, as none of those blocks would be accepted by the rest of the network, it's pointless to 'cheat' the system. Which is how Bitcoin basically works: because every node on the network has to store the complete block chain, it can verify every single transaction and block there has ever been, and changes to the mining code aren't dangerous.
Tom is exactly right. The network is designed to only accept new blocks generated from the longest blockchain and with the correct solution to the proof of work problem. To lower the difficulty without the consent of the entire network would result in a rejected fork.
As the network is a distributive clock, it is possible for two miners to have two valid solutions at the same time, which is resolved by the solution to the next block. Whichever blockchain gets a new block first wins.