Plaid Cymru has secured a historic by-election win in Caerphilly, seeing off Reform UK to take the vacant Senedd seat.