It is not an easy task but it is definitely possible to switch your branch in the 2nd year but there are certain conditions you need to fulfill:
There is, however, an unsaid rule, if you wish to apply to a more intense branch-like CSE from a Mechanical, your request may not go through at all. However, if it is from a less intensive branch to a similar branch, based on your academic performance they will consider your request.
Moreover, the procedure would involve getting permission from your HOD to make sure you have a great class performance, if not, at least a decent reputation in the batch. They would not consider requests from the troublemakers of the batch.
So, if you think you might want to switch later after the first year, do keep this in mind, it might help.