Large tech companies such as Google and Facebook will have to abide by new competition rules in the UK or risk facing huge fines, the government said.