Noah Cates and Kevin Hayes each had a goal and an assist for Philadelphia (23-42-11), which has lost five in a row. Felix Sandstrom made 35 saves.
"At different points, I'd say it's a matter of execution," Flyers coach Mike Yeo said. "At different points, it's a matter of puck support. But the ability to advance the puck, to get the puck out of our zone and to get onto the attack, too many times that turned into chances against or goals against here tonight."
Hayes gave Philadelphia a 1-0 lead at 1:16 of the first period after he pushed the puck between the skates of Buffalo rookie defenseman Owen Power.
Olofsson tied it 1-1 with a one-timer from the right face-off circle at 8:36 for a power-play goal.
Anders Bjork put the Sabres ahead 2-1 at 17:34 when he took advantage of a Flyers line change to break in alone and shot past Sandstrom's glove. It was Bjork's first goal since Dec. 14.
"It was a little interesting because I had way more time than I thought I would," Bjork said. "It's unexpected, a little bit of a surprise. I tried to stay calm and get a good shot off."
Philadelphia tied it 2-2 at 1:20 of the second period after video review showed Cates pushed the puck over the goal line before the referee blew his whistle, but Olofsson scored another power-play goal with another one-timer from the right circle at 9:43 to give Buffalo a 3-2 lead.
The Sabres went 2-for-2 with the man-advantage.
"They have a lot of good shooters and both sides, so that makes it hard to defend against," Sandstrom said. "They have options like that. I think we did a good job staying on the inside, but we have to go harder on the top. Unfortunately, we had a couple go in (on the penalty kill)."
Thompson made it 4-2 with his 35th goal of the season, a wrist shot from between the circles at 14:22.
Zack MacEwen cut it to 4-3 at 14:07 of the third period on a rebound Oskar Lindblom's shot, but Thompson scored an empty-net goal with 32 seconds left for the 5-3 final.
Thompson is tied for the most goals by a Sabres player since Jack Eichel scored 36 in 2019-20.
Granato coached Thompson at the USA Hockey National Team Development Program Under-18 team in 2014-15 and said the roots of Thompson's success were seen in the skill level and maturity the forward displayed then.
"I first had him when he was 17 years old," Granato said. "And I can tell you then, I was sad to see to our season end, sad that I wasn't coaching him anymore. But this is why, because he just has so much potential."