Biggest factor in this was the removal of swappable batteries.
It wasn't battery sales, Samsung! It was the option to be able to go from 5% to 100%. The option to replace a battery after a year if needed.
The removal of that option and the removal of the SD card slot in the S6 Edge were the start of the decline. (not counting the S5 because it wasn't much of an upgrade--which was a major cause in itself)
So you're probably asking, that can't be enough...
The result of taking out the replaceable battery and SD card slot was Samsung just became like any other phone.
Well, when Samsung became just like Apple and other phones, it became just a matter of:
#1 who has a better deal - 2 for 1, 50% off, $300 gift card, free gifts, etc.
#2 who has a better (auto) camera - Apple won this. More prefer Apples pictures, speed, and low lighting shots. If you ever ask anyone with an Apple or why they moved from Android to Apple or why they prefer Apple phones to Android, the camera reason is within their top 3 reasons if it isn't the #1 reason. Especially when Apple did the automatic bokeh effect with the iPhone7.
#3 People that switched to Apple can't easily switch back once they start investing in Apple's costly traps.
But it's starting to get better...
#1 I hope the person who suggested taking out the SD Card slot was fired. Because it's return was a good move. It brought back a 'comfort' to people.
#2 Note8 isn't exploding (yet). The Note series is a niche that Samsung hasn't gotten rid of, and sells well when it doesn't explode. But the keyword here is 'Niche'.
There are alot of us heavy users that isn't in the office all day or who doesn't want to be constantly connected to a wire. Wireless charging? That's fine. It slightly creates more ease for the consumer, which is good, but placing your phone on a wireless charger that has a wire attached to the charger is kind of dumb.
Don't fix what wasn't broken. Make it better instead. And please stop copying Apple on it's stupidity. The design of the iPhoneX is probably the best, so copy that. It is the perfect thickness. Perfect screen size. Perfect length and width.
Headphone jack is also a Niche. Do not take those away. You don't need to!
Replaceable battery was a niche to LG, but they've dumped it and wallah! They're flagships sales declined. Sales willgo back to Samsung or Google and some to Apple, since it's all the same now anyways.
Bring back replaceable batteries and get back all the sales from heavy phone users! Find a way to bring it back with the current designs, even if you have to use thinner batteries with lower capacity---compensated by including a FREE secondary battery and a battery charging case (like the LGv10/20).
Go ahead and try to bring it back. At this point, it won't hurt your sales anyways.
Go back to basics Samsung---consumer's comfort and ease above all.