As others have mentioned before it depends on the context.
From the perspective of HR departments, "Senior" means "Has worked in this field for at least N years, and therefore can command a salary between $X and $(X+Y)". You become one by keep working on the field, but I don't think this is what you asked.
From the perspective of management, "Senior" means "can work on roughly defined goals with minimal supervision". Contrast that with "Intern" := "Needs micromanagement" and "JuniorDev" := "Can work independently, but needs to be assigned well specified tasks". Please note that this is only weakly correlated with your technical expertise, and has more to do with your ability to work around issues beyond your direct control: How do you learn stuff on your own. How do you reach out for help when you get stuck. How do you resolve conflicts when your perceived goals get in the way of those of your team member's, or viceversa.
You learn to do this by doing (that's why HR uses the proxy of "N years of experience"), but more than that you learn by striving to keep a good attitude and not allow roadblocks to stop you from completing your assigned tasks. It also help a lot if you learn to listen to people and try to figure out how to fix the problem at hand for good (instead of doing the bare minimum to get a perfect row of check marks on your weekly report).
Finally, from developers perspective "Senior" means "is an expert in X, Y or Z technology". This usually gets in conflict with the manager's definition and causes a lot of unneeded friction and resentment. You obviously do this by working on something that interest you, but the not so obvious part is that you have to try to avoid doing work too far from your intended area of expertise. This is what some people call "quality work" (vs simply "chores"). You cannot always avoid chores, neither should you aim to... but if you get too sucked into them, you will have a hard time building up expertise.
From the perspective of HR departments, "Senior" means "Has worked in this field for at least N years, and therefore can command a salary between $X and $(X+Y)". You become one by keep working on the field, but I don't think this is what you asked.
From the perspective of management, "Senior" means "can work on roughly defined goals with minimal supervision". Contrast that with "Intern" := "Needs micromanagement" and "JuniorDev" := "Can work independently, but needs to be assigned well specified tasks". Please note that this is only weakly correlated with your technical expertise, and has more to do with your ability to work around issues beyond your direct control: How do you learn stuff on your own. How do you reach out for help when you get stuck. How do you resolve conflicts when your perceived goals get in the way of those of your team member's, or viceversa.
You learn to do this by doing (that's why HR uses the proxy of "N years of experience"), but more than that you learn by striving to keep a good attitude and not allow roadblocks to stop you from completing your assigned tasks. It also help a lot if you learn to listen to people and try to figure out how to fix the problem at hand for good (instead of doing the bare minimum to get a perfect row of check marks on your weekly report).
Finally, from developers perspective "Senior" means "is an expert in X, Y or Z technology". This usually gets in conflict with the manager's definition and causes a lot of unneeded friction and resentment. You obviously do this by working on something that interest you, but the not so obvious part is that you have to try to avoid doing work too far from your intended area of expertise. This is what some people call "quality work" (vs simply "chores"). You cannot always avoid chores, neither should you aim to... but if you get too sucked into them, you will have a hard time building up expertise.