Once upon a time I noticed roughly this but didn't know what to do with it. I would rephrase as follows.

Any category $C$ has an associated "category algebra" $k[C]$ spanned by the morphisms of $C$ where the product of two morphisms is $0$ if they can't compose and their composition otherwise. This algebra is unital iff $C$ has finitely many objects; in this case it can be thought of as the endomorphism algebra of a formal direct sum of all of the objects of $C$. If $C$ is the one-object category associated to a group $G$, then $k[C] \cong k[G]$. Somewhat more generally the following is true.

**Theorem:** Let $C$ be a groupoid with finitely many objects. Suppose $C$ is the disjoint union of connected groupoids $C_i$ with $n_i$ objects, each of which is isomorphic, and each of which has automorphism groups $G_i$. Then

$$k[C] \cong \bigoplus_i M_{n_i}(k[G_i]).$$

In particular, the Morita equivalence class of $k[C]$ only depends on the homotopy type (by which I mean equivalence class under equivalence of categories) of $C$, and $k[C]$ is a matrix algebra over $k$ iff $C$ is contractible (by which I mean equivalent to the terminal groupoid).

I don't have a conceptual explanation of this, though. By a conceptual explanation I mean one would want to upgrade $C \mapsto k[C]$ to a $2$-functor from the $2$-category $\text{Cat}$ of categories, functors, and natural transformations to the $2$-category $\text{Bimod}$ of rings, bimodule categories, and bimodule homomorphisms (equivalence in this $2$-category is Morita equivalence), but as far as I can tell $C \mapsto k[C]$ is not even a functor! (The problem is that functors can cause morphisms which were previously not composable to become composable.) Perhaps one should instead talk about the free $k$-linear category on $C$...

**Edit:** Aha! We should definitely instead be talking about the free $k$-linear category on $C$, which I will confusingly also denote $k[C]$. Sorry about that.

But now $C \mapsto k[C]$ is a $2$-functor. It takes values in the $2$-category of $k$-linear categories, functors, and natural transformations, and so in particular it sends equivalent categories to equivalent $k$-linear categories. Now the problem reduces to understanding why equivalent $k$-linear categories give rise to Morita equivalent rings. It will be helpful, but not necessary, to be aware that Morita theory naturally generalizes to $k$-linear categories as follows.

**Theorem:** Let $R, S$ be $k$-linear categories (thought of as generalizations of $k$-algebras, which we reduce to when $R, S$ have one object). The categories $\text{Mod}(R), \text{Mod}(S)$ of functors $R^{op} \to k\text{-Mod}, S^{op} \to k\text{-Mod}$ (thought of as either analogues of presheaves or generalizations of right modules) are equivalent if and only if $R$ and $S$ have equivalent Cauchy completions.

Here the Cauchy completion of a $k$-linear category $R$ is obtained from $R$ by first adjoining formal direct sums and then splitting idempotents. It is a slight generalization of the Karoubi envelope, which figures in the corresponding theorem for ordinary categories.

*Example.* Let $R$ be the one-object $k$-linear category associated to a ring which I will, again confusingly, also denote by $R$. Adjoining formal direct sums gives us the category of finitely generated free right $R$-modules, while splitting idempotents gives us the category of finitely generated projective right $R$-modules.

Now we just need one more observation.

**Observation:** Let $R$ be a $k$-linear category with finitely many objects. Then $\text{Mod}(R)$ is equivalent to the module category of the endomorphism ring of the formal direct sum of the objects of $R$.

You can just verify this directly or, a little more abstractly, observe that the identity morphisms of the objects of $R$ become idempotents in the endomorphism ring, and roughly speaking splitting these idempotents gives us our original objects back.

So, to recap:

- Suppose $C$ and $D$ are equivalent groupoids with finitely many objects.
- Then the free $k$-linear categories $k[C]$ and $k[D]$ are equivalent, and hence have equivalent module categories.
- Since $k[C]$ and $k[D]$ have finitely many objects we can replace them with the endomorphism rings of the formal direct sum of all their objects, and the result is two Morita equivalent rings.