In the Peter Pan cartoon or movie how did the clock in the crocodile's stomach stay running all that time?
Neverland magic. Or the croc had a taste for clocks and just ate multiple of them over the course of years.
Real wind-up clocks only last for 10 days per wind, of accurate time keeping. It will slowly stop completely a few weeks after that, month and a half at most.
There is also the possibility that Hook simply imagined the ticking, part of a psychological phobia or post traumatic stress disorder. Nearly being killed by a giant crocodile is very traumatic, I'd imagine.
Of course, time doesn't work the same way in Neverland. People don't age. Imaginary food is real and keeps them alive. A touch of Fae dust and happy thoughts make you fly. So it's not inconsistent that a wind-up clock in Neverland never needs winding. Or Hook's fear of the clock keeps it ticking. It's only as real as Hook's mind allows it to be.
In the source book (Peter Pan and Wendy) the clock does indeed stop ticking. Peter surmises that it's wound down but hits upon the ruse of making the ticking sound himself so that predators will think he's the crocodile and be scared away:
Odd things happen to all of us on our way through life without our noticing for a time that they have happened. Thus, to take an instance, we suddenly discover that we have been deaf in one ear for we don't know how long, but, say, half an hour. Now such an experience had come that night to Peter. When last we saw him he was stealing across the island with one finger to his lips and his dagger at the ready. He had seen the crocodile pass by without noticing anything peculiar about it, but by and by he remembered that it had not been ticking. At first he thought this eerie, but soon he concluded rightly that the clock had run down.
Without giving a thought to what might be the feelings of a fellow-creature thus abruptly deprived of its closest companion, Peter at once considered how he could turn the catastrophe to his own use; and he decided to tick, so that wild beasts should believe he was the crocodile and let him pass unmolested. He ticked superbly, but with one unforeseen result. The crocodile was among those who heard the sound, and it followed him, though whether with the purpose of regaining what it had lost, or merely as a friend under the belief that it was again ticking itself, will never be certainly known, for, like all slaves to a fixed idea, it was a stupid beast.
Peter reached the shore without mishap, and went straight on; his legs encountering the water as if quite unaware that they had entered a new element. Thus many animals pass from land to water, but no other human of whom I know. As he swam he had but one thought: 'Hook or me this time.' He had ticked so long that he now went on ticking without knowing that he was doing it. Had he known he would have stopped, for to board the brig by the help of the tick, though an ingenious idea, had not occurred to him.
As far as the film is concerned, the clock seems to continue operating merely by the power of movie magic.
In Neverland, with a bit of pixie dust, believing you can fly, MAKES you fly. On Earth, Angel-dust gets you "wound up", and some people call it flying. If time flies when you are having fun, then time can also get wound-up. Since time that is wound-up is inside the clock, the clock can also get wound up.
The crocodile has probably eaten MANY lost-boys and fairies over the years. This keeps the clock dusted instead of wound.
Also, bringing back a fairy from the dead, requires you to clap your hands. Being dead your heart stops. A heart is sometimes called a "ticker" because it is similar to a clock. Clapping your hands restarts tickers. A little-known fact about magic is that it is VERY literal, this is why results are unpredictable to untrained practitioners. Clapping also restarts clocks when in a magical realm. Many watch companies here on earth have semi-successfully duplicated the effect in their kinetic wrist-watches.