What if you painted your eyelids purple before taking a test and passed? Would you claim that painting your eyelids purple was responsible for passing the test?

Your illogical conclusion that niacin had caused you to pass is known as a fallacy of causation. Youre merely assuming that niacin was responsible.
Just because B happened doesnt mean A caused it.

Nothing but a pure coincidence.