For me, inspiration comes from the strangest of places, and that can indeed include something I’ve read.
The key, though, is the definition of plagiarism. The Grammarly blog has a good post about plagiarism: https://www.grammarly.com/blog/types-of-plagiarism/ The thing to keep in mind is that there are common tropes shared by many stories and novels, and certain genres of writing tend to follow a very similar pattern (such as mysteries, or horror fiction). So, just deciding that you really liked that pairing, and want to write something yourself in that fandom for that pairing doesn’t constitute plagiarism. If you put that pairing in the exact same scenario, with the same events, then you’re crossing the line.