My cousin had got a branch change from Mechanical engineering to Electronics engineering (ECE). He shared his experience with me of how easy it was to get a branch change.
The primary and most important thing is to be regular and give equal attention to all subjects. You have to focus on your studies only and not let any distractions take the better of you. Be firm on your goal and give up all time-wasting activities.
You need to be rightly motivated and determined to achieve these goals. Not losing hope is the key as one or two exams do not define you. You will get ample opportunities to prove yourself so just keep working hard.
My cousin scored below average in the middle of the 2nd semester. However, she got this sudden motivation and studied hard and was able to score an overall CGPA of 9.64. She studied consistently every day and was able to change her branch eventually.