It is true that fiction can be anything your imagination will allow. But there is a but and it’s a big but. The internal logic must be there. If you have a world where all elephants are pink, then you can not have a blue one unless something has happened to turn it blue.
While you may not be able to research it in books, you can do background research. For instance, my race of beings from the Shaytonian Chronicles have purple blood. They were still oxygen breathers, so I needed a mineral that would oxidise readily and come out purple. A bit of research showed manganese gives a purple oxide that, if pure enough, could be used to make battery acid. As I was using them as living batteries (or at least my villain was) this was perfect.
Once you have decided a “fact” then you must be consistent throughout the book. This can be hard as you get further into the tale and get caught up in the action. A good editor will help haul you up and spot inconsistencies.
Or give it to a twelve year old. Mine will spot a logic error in five seconds flat, even though she will accept almost anything as a feasible starting place to reason from. You can say all elephants are pink and she will go, “OK, but here you have it hiding in a strawberry patch and then in candy floss. That’s two different types of pink. Which one are they?”
As any sci fi fan knows, inconsistencies creep in to even the best plots (take Star Trek, they were devils for it). Loyal fans will accept some errors, even have a ball writing fan fic that explains them, but if too many errors appear, you have lost them. Can you remember an error that turned you off a book?