You can apply to both MI5 and MI6 as they are two different organizations with different sets of activities. If you don’t get selected in one you can get selected in the other but you might have to check their eligibility criteria and application requirements before sending in your applications to them