"Element not found" issue occurred from time to time

Hi everyone,
I have written a code and it has 4 areas and my code is a little bit longer. When I compile all 4 areas within one attempt, sometimes the code is working properly, but sometimes not and it is shown below error;

" Element with locator ‘xpath=//input[@id=‘submit3’]’ not found. "

If I compile only one area (By commenting other three areas) it works fine. Otherwise, most of the time, it displays the error that I mentioned earlier. I want to compile the whole code within one attempt.

And also sometimes, the XPaths that worked previous days are not working now. So, I have to find those Xpaths so many times.

I searched about this matter to find the solution but I couldn’t do it.
So, I want to know the reasons for the above-mentioned problems and need your suggestions and solutions to solve those issues.
So, I kindly request you to help me to fix those issues. Thanks all.