Cantor Fitzgerald LP agreed to buy UBS Group AG’s O’Connor unit, ending more than three decades of ownership by the Swiss bank and placing the hedge fund back in control of one of its early founders.