Britain's opposition Labour Party and the UK Independence Party suffered defeats at separate parliamentary by-elections.