It's totally ok to write chapters out of order! In fact, a lot of authors, both professional and aspiring, do it all the time. Writing out of order can offer some distinct benefits, including allowing you to tackle the parts of your story that excite you the most, and build momentum while avoiding burnout. It can also be useful when you have a clear idea of how different aspects of the story interact with each other, as you can get on with writing the ‘tricky’ chapters which would otherwise be daunting.
On the other hand, it can take a lot of extra time and effort to plan, revise and ensure the continuity of your story. Writing the chapters in sequence can often make the process easier and more efficient. In the end, it’s really up to you, and whatever works best for your writing style. So if you’re one of those people who would like to try writing out of order, go ahead - you never know, you might be surprised by the results. Good luck!