This isn’t a bug in your code. In React, Strict Mode mounts components twice in development to help catching bugs. That’s why your useEffect runs twice while developing, but don't worry it will run only once in production.
https://react.dev/reference/react/StrictMode