How does a government lose a vote? Who were they voting against?
"Government" in the UK refers to the prime minister and his/her cabinet. I guess its kind of similar to the "administration" in the US. Most ideas/ laws they put forward have to be voted on by MPs (including the 30 MPs that make up the cabinet). There aren't any executive powers for the government. Anyone can put forward a vote/ amendment to a current bill to parliament. The ones put forward by the government are always agreed by cabinet and are expected to pass through the house.
Normally, the ruling government's party has a majority in the house and their own party will vote with them, meaning pretty much all motions they put forward are voted "aye". Sometimes there are rebels within a party but they usually aren't numerous enough to force a loss.
This current government has only 317 MPs (out of 650) and are held up by a confidence and supply agreement with the DUP (who have 10 MPs). Sinn Fein hold 7 seats (Irish party) and they never vote, so total voting MPs are 643.
Normally on a huge deal for the government like this, the entire opposition will vote against them (316 in this case). However, the DUP won't vote for the deal due to parts of the deal about Northern Ireland and in fact said they'll vote no, so that was 326 total against.
So at this point, the government needed the entirety of their own party to vote for their deal plus they would need 5 members of the opposition to flip and vote for them. What actually happened was that over 100 conservatives voted against their own government (which was roughly expected, but not quite in the number that actually happened), and the government lost by a massive margin.