It depends. Sometimes stories about dogs can be based on real events, but often they might be fictional or have elements of imagination mixed in.
It's not straightforward to determine. If the author claims it's true or it's documented as a real account, then it likely is. But many dog stories are just created to engage and entertain readers, not based on actual facts.