There are C(6,4)=15 ways to choose 4 out of 6 flags. 5 of the 15 choices contain a red flag, so the probability of having a red flag in the 4 flags is 10/15=2/3.
The probability for the red flag to be at the top is 1/4 and to be at the bottom is 1/4, so the probability for it to be top or bottom is 1/4+1/4=1/2.
Therefore the total probability is 2/3*1/2=1/3.