Jeffrey M. Chemerinsky, a US Attorney and former Federal Prosecutor wrote about almost exactly this question in the USA in "Counting Offenses".
It's a 38 page document, so I won't attempt to paraphrase it in full here, but I can give some gists taken from reading it as a non-lawer / non-expert and non-American. The document is free to download from Duke.
Counting offences matters because among other things it has implications for sentencing, double jeopardy, and triggering specific statutes about repeat offending.
The starting point seems to be that any continuous un-interrupted act is a single offence, and can only be charged as one offence. In some cases an act can be divided and successfully charged as multiple offences, but there is not any great consistently applied rationale for how to do so. There are many cases where the division of course of conduct into multiple offences for charging has been disputed and courts have ruled in various ways.
When a statute specifically sets a "unit of prosecution" then the courts can follow that, as in the case of "a statute that made each day of practicing medicine without a license its own crime". But it is extremely rare that legislators specify a unit in this way.
Chemerinsky does not mention a specific case of illegally possessing a weapon for a long time, but he talks about the case of In re Snow, where the Supreme Court determined that a long period of illegal cohabitation should be charged as only a single offence. And Chemerinsky considers a hypothetical cases of a gun being illegally possessed for a year and concludes that "[convicting one count for each week and thus] sentencing this defendant to 260 years in prison [would violate the Eighth Amendment]".
There is no discussion of speeding offences, but there is discussion of Foley v. Commonwealth in which the Court of Appeals of Kentucky "held that multiple convictions for fleeing and evading law enforcement violated the prohibition on double jeopardy", as the court ruled "that fleeing or evading, under circumstances as occurred in this case, is a single continuous act, regardless of how many police officers may be considered to have given an order to stop.”"
Many of the crimes where this has been an issue have been violent crimes, which is something that I didn't consider in my question.
It seems that generally repeated violent acts done effectively continuously in a very short time frame, all of the same type and for the same reasons, in the same event, and without interruption may only be charged as a single offence, while acts that are spread over a longer time, or with some interruption between them, or where there was a so-called "a fork in the road" "giving the defendant a chance to stop and reconsider his" separating acts, then acts before and after the "fork" can be charged as separate offences. But there seems to be a lot of uncertainty and inconsistency in how courts have dealt with this between different cases.
Jeffrey M. Chemerinsky, Counting Offenses, 58 Duke Law Journal 709-746 (2009)
Available at: https://scholarship.law.duke.edu/dlj/vol58/iss4/4