If you call an ad hoc meeting of your knitting buddies, it means the meeting was formed for one particular reason — to knit. Anything ad hoc is either done for one specific purpose, or in an impromptu, last-minute way.
Ad hoc comes from the Latin words meaning "for this." Often the term is used as a criticism, in the sense that something done ad hoc is done hastily and can be ill thought out, serving only to address a problem in the short term. Government programs are often described as ad hoc, for example. But the term can also imply a sense of ingenuity, of impromptu brilliance, or of something happily care-free and devoid of fuss. Like your ad hoc knitting event!