Jakub Voracek had a goal and an assist for Philadelphia (18-15-5), and Carter Hart made 22 saves.
Philadelphia won 3-2 in overtime at Boston on Monday.
"I thought our guys played with urgency, I thought we played the right way," Flyers coach Alain Vigneault said. "We checked when it was time to check. We didn't give them a lot of looks. We got some great looks, we weren't able to finish, and they were able to finish. That was the difference in tonight's game."
Bergeron gave the Bruins a 1-0 lead at 7:09 of the first period. Craig Smith tipped Marchand's shot off Hart's chest, and the rebound went to Bergeron, who scored his 900th NHL point.
The Bruins captain then made it 2-0 at 17:31 with a power-play goal.
Voracek got the Flyers within 2-1 at 1:33 of the second period, and Shayne Gostisbehere scored from the right side to make it 2-2 at 4:03.
The Flyers outshot the Bruins 25-7 in the second period.
"He was battling all night and gave us a true chance to win, especially in that second period," Bergeron said of Swayman. "That poise was evident from the get-go, from the way that he prepared in the locker room. He looked ready, looked calm and he was the same way on the ice."
Swayman saved a breakaway by Scott Laughton to start the play that led to Bergeron's second goal.
"At the end of the day my job is to stop pucks and that's what I wanted to do for the team in order to give them a chance to win," the 22-year-old said. "I know if I do my job they're going to do theirs, and that's exactly what happened tonight."
Marchand gave the Bruins a 3-2 lead at 8:21 of the third period. He forced a turnover in the defensive zone and joined Jeremy Lauzon for a 2-on-1. Lauzon passed to Marchand, who deked and slid the puck between Hart's pads.
Bergeron finished his hat trick with an empty net goal at 19:37 for the 4-2 final.
Marchand and Bergeron combined for seven points and seven of Boston's 26 shots on goal.
"They're elite players in the League," Cassidy said. "They're always talked about when it comes to leadership in Boston and throughout the League.
"Tonight they were clearly our two best forwards. ... I can't say enough about them. They obviously were difference-makers tonight, and we needed it."
The Flyers had four shots on goal in the third period.
"We had a really good second," Gostisbehere said. "We tried to come out in the third. They had a really good start. It was back and forth. Obviously they get a shorthanded goal and that changes the period. ... We had our chances, but it's a tough one out there."