They are two somewhat related concepts
Detrimental reliance is basically - I was told I could do something, I relied upon the government telling me that, I did it, and then the government tries to invalidate what I did - even though I relied in good faith on the government’s instructions.
I ask to build a house within 10 feet of a lot line and zoning told me I could. I do it. Then later, zoning changes its decision and says I have to tear the house down. Shouldn’t be able to do that because I detrimentally relied on the government decision at the time.
Same with settled expectations - involves an issue that has been settled. How taxes are calculated for investments for example. People and industries rely on that determination - make substantial investments of money based on that interpretation. Then, at a later date, that determination is reversed mid-course.
The doctrine suggests that courts should tread lightly if a decision would disturb settled expectations or that they should make their decisions prospective only to lessen the impact.
Both concepts are in play with elections. If you are interested, go to Marc Elias Twitter feed. He’s a litigator for the DNC on elections issues, but he posts all sides briefs and all court rulings on his cases.
Really interesting wonky reading if you are interested in a deeper dive.