Real Madrid secured a crucial 2-1 win against Alaves, ending a four-match winless streak in all competitions and bolstering their LaLiga standing.