Republican missteps have helped to spotlight the party’s divisions on abortion and same-sex marriage, two issues on which their base is out of step with the general public.