Intuition behind this specific algorithm for time series
During the forward pass, you compute F such that F[i] represents the maximum possible profit when restricting yourself to the elements with indices 0,1..,i.

During the backward pass, you compute B such that B[i] represents the maximum possible profit when restricting yourself to the elements with indices i,i+1,..,n-1 (where n is the size of your list). The reason you track the max is that because you are going backwards in time when populating B, you want to sell before you buy.

Now M[i] = F[i-1] + B[i] represents the maximum profit when doing a first buy/sell among indices 0,1..,i-1 and a second buy/sell among indices i,i+1..,n-1, so you are sure that the first sell will happen before the second buy (because the first sell happens at index i-1 at the latest and the second buy at index i at the earliest).

Reciprocally, suppose the optimal solution has two buy/sell's happening at indices b1, s1, b2, s2 (in increasing order). Then you know that M[b2] will be at least as big as the profit achieved by this solution (equal in fact, because it can't be bigger) as b1,s1 happens before index b2, and b2,s2 happens after (or at) b2.

Thus, by taking the maximum over all M[i] you will necessarily hit M[b2] at some point and get the maximum profit. And if the optimal solution has only one buy/sell it will be at M[0] = F[n-1] = B[0] = M[n-1] which you also consider.