"... the TNG episode “Tapestry” has both a consistent effect and a changing timeline. Q gives Picard the chance to go back to his youth and make better choices. Once Picard realizes his error (getting into the fight with the Nausicaan and getting stabbed in the heart was somehow the best outcome for him), he’s given the opportunity to restore his original choices. This time, as he’s stabbed through the heart, he laughs. Interestingly, it had been mentioned in a previous episode, “Samaritan Snare,” that he had laughed when stabbed—indicating that his experience in the past had always been a part of Picard’s history."
TV More specifically what seems like an excellent survey from Ars Technica of the mechanics of the Star Trek's time travel episodes during which it becomes apparent that like all shared franchise universes there's rarely any particularly consistent decisions about such but then heads of into some real science which suggests ... oh just read the thing. This is from earlier to shield you from spoiling the ensuing engrossing text: