Hi and hope all is well,
Answer to your first question:
Usually 2 years. This is also enough time for them to forget about you, which gives you a good chance to start fresh once you re-apply.
Answer to your second question:
I would consider why you got rejected after the second round. If you passed the CV filtering and the first round, it most likely means that there is no significant or unachieavable difference between you and those that get the offer. Perhaps it was more of a fit issue, or you did not crack the personal part of the interviews, or there were just too many good candidates during your recruiting season.
The interviewers probably gave you a feedback. If not, the first act I would recommend is to actually ASK them for it and try to get a better understanding as to why you got rejected at the 2nd round. This will also show them how determined you are and how bad you want the job, which will portray a positive image of you. (Just dont push too hard, there is a fine line between pushing and pushing too hard)
When it comes to what you can do in the meantime, there is not one simple answer to this. My take would be, do whatever it is that you would enjoy doing and you think you will be good at. This can be entrepreneurship, working at a startup, becoming a YouTuber, working at a bank, anything. Because, any "different" experience that you gain during these two years that you enjoy and test yourself will be much more valuable than a text book next step. You will have a story to tell when you try for the second time.
Below are some of my practical next step recommendations:
1) Network and meet with as many people as possible from the firms you want to re-apply to. You can also ask them for an advice as to what you can do in the meantime. Maybe they have an opportunity that you might be interested in
2) Practice and sharpen your interview skills. Practice, practice and practice
3) If and only if you are genuinely interested, apply for positions at your dream firm's clients and look to be a team leader on the client side for their project, this will increase your exposure to them
4) Test if you actually like consulting. You can do that by basically giving free advice to anyone that is asking for it in areas where you have credibility. This will also sharpen your people skills as a consultant.
5) Do not give up. Seriously, if you got rejected at 2nd round, you have what it takes. If you want it bad enough, you will get it. 2 years is not that long.
Good luck and cheers