Is there an idiom that means something is inconsistent with the contexts or facts? Like when a book is written and the plot and the world-building doesn't go hand in hand and are inconsistent with each other. Is there an idiom we can use to describe such situations?
There are probably a few idioms, words or sayings you could use.
An inconsistency between tone and content might be described as "not in keeping with" (eg "the tone is not in keeping with the content") You might also say "out of harmony with".
"It sticks out like a sore thumb" or "it stands out a mile" are both sayings that can refer to anything which is out of place.
Something appearing out of place might be described as "alien", "awkward", or it might be said to "clash" with other things or details.
Something inconsistent might also be said to be "amiss", or "aberrant" (great word, not often used though)