I thought the majority votes in a particular state determined the outcome for that state. For example, if the majority votes Democrat, delegates are given to the Democratic nominee per state law. I cannot, therefore, understand why people care about how electoral districts are counted.
Gerrymandering works by concentrating people who will vote for the other party in as few districts as possible while spreading out voters for your party as widely as possible. A perfect gerrymander would put 50% plus one voter in as many districts as possible and then putting 100% of the other party in the remaining districts.
To put some numbers on it, assume that there are 5000 voters evenly split between the two parties and there are eight districts. Each district has exactly 625 voters. So the gerrymandering party would fill as many districts as possible with 313 of their voters and 312 of the other party. That would seven districts with 2191 of their voters total. The 309 remaining voters would not be enough to gerrymander the remaining district to their side. So an even split in voters turns into a seven to one split in the legislature.
In the real world, there is enough variability from election to election that they tend to avoid such even districts and instead draw districts more like 55% to 45%. Also, they have less control over voters than this example shows. For example, many households have voters from more than one party. Also, some voters themselves vote for candidates from both parties. And of course, the rules may not allow them to arbitrarily assign households to one district or the other. They tend to require contiguous districts. This means that if a household is surrounded by households in one district, it won't be in another.
It depends on the state. In the Democratic presidential primaries, almost all states award delegates proportionally to everyone who meets the 15% threshold in the statewide vote. There are some exceptions though. For example, Washington state awards some delegates based on the statewide vote but awards others based on the vote in each congressional district.
Gerrymandering usually won't affect this much, but in a Republican-gerrymandered state like Florida, Texas, or North Carolina, it can have some impact on the Democratic race. In those states, Republicans will tend to put as many minority voters into as few districts as possible. Since black voters are more likely to vote for Hillary Clinton, this may compress her votes into fewer districts than Bernie Sanders' voters.
It's also worth noting that while some of that may be gerrymandering, some is also simple geography. Sanders tends to do better with young, white, and liberal voters; Clinton does better with older, minority, and moderate voters. To some extent people who think alike are more likely to clump together.
In the general election, most states award electors winner-take-all statewide. There are a couple exceptions though. In particular, Nebraska and Maine award delegates winner-take-all by congressional district (with the two Senate seats being statewide). So it is possible for a party to gerrymander seats such that they may vote against the statewide result.
Nebraska doesn't do this. Their gerrymander tries to cement their statewide advantage into an advantage in all House races. Maine may have done this, as Republicans have the most control there since they stopped being a reliably Republican state. Republicans might pick up an extra elector on that basis. It's not clear that that elector would matter. Few projections put them with 268 or 269 other electors such that it would matter. Note that Republicans need 269 electors to tie (sending it to the House) or 270 to win.
Gerrymandering matters more in terms of legislative races. Since redistricting is done by the state, statewide races aren't impacted as much. Federal House races and state legislative races are impacted more.
Recent Supreme Court decision
There was a recent Supreme Court decision that could affect redistricting. It wouldn't really have changed the basic gerrymander calculation, but what it could have done was shift the size of Republican districts. This wouldn't matter to the presidential general election in Texas. All those electors would still go the same way. It could have mattered in Nebraska or Maine.
The major change though is that it would have required Texas to add more voters to the Democratic districts and shrink the Republican districts (Republican districts tend to have larger voting populations). This had the potential to increase the Republicans' advantage in their congressional delegation.
It's also worth noting that while the Court did not rule that states had to balance voter population by district, it also did not say that they couldn't. This was a rather narrow holding and not unexpected. The major hope had actually been that the Court might explicitly say that voter population was allowed. As is, Texas or another Republican state might redistrict based on that metric and try to get a future decision on that point.
Such a decision could change the reapportioning of districts after the next census in 2020. If they apportion House districts among the states by voter population rather than total population, it could shift districts (and therefore presidential electors) from fast-growing, younger states to older states. Texas, Arizona, and California are states that might lose electors. States like Iowa, Wisconsin, and Pennsylvania might gain.
It's not as clear that this would help Republicans at the state level, although it might. Taking electors away from California would be to their advantage. Giving electors to Pennsylvania might not be. Giving electors to states like Montana and South Carolina would help them.
One analysis suggests that it would be a wash in Republican states. Texas would lose four electors while Louisiana, Kentucky, Missouri, and Montana would each gain one. Clearly Democratic states would lose four electors, mostly due to losing six in California and one in New York. Swing states would gain four electors in Iowa, Virginia, Ohio, and North Carolina.
It's worth noting that the current case was just about redistricting in a state. It didn't say anything whatsoever about apportionment between states. People talking about apportionment changes always were hoping for future changes.
This is generally not an issue for presidential races for the reason you mentioned, but House of Representatives districts are often said to be Gerrymandered to favor the party which draws the lines. I've included a short description of how this is possible:
Consider the case where a state with one big city has 50% of the total population supporting party A and 50% supporting party B. The state also has 3 house of representatives districts. 70% of the people in the city vote for party A consistently and 70% of people in the rural areas vote for party B consistently.
If party B draws the house district boundaries, then they can make the city its own district and have 2 districts that have a small amount of city and are mostly rural. Then party B will almost always win the 2 mostly rural districts while party A will only win the entirely city one.
If party A draws the house district boundaries, then they can cut the city in half, with each half of the city in its own district with some rural areas. They would then make the last district solely rural. In this case, part B would win just the one completely rural district, and party A would win the 2 districts that have mostly city voters.
In this case either option seems to give unfair congressional representation to whoever draws the lines.