Let $\mathbf{H}$ be an $\infty$-topos (in your case, you want to take the $\infty$-topos of spaces, $\mathcal{S}$). There is an equivalence of $\infty$-categories
$$
\Omega : \operatorname{Grp}(\mathbf{H}) \to \mathbf{H}^{\ast/}_{\geq 1}, \quad \mathbf{B} : \mathbf{H}^{\ast/}_{\geq 1} \to \operatorname{Grp}(\mathbf{H})
$$
between the $\infty$-categories of $\infty$-group objects in $\mathbf{H}$ (with $\infty$-group homomorphisms between them) and that of pointed, connected objects in $\mathbf{H}$ (where maps should respect the basepoints), mediated by the usual looping and delooping functors —here $\Omega$ is left adjoint to $\mathbf{B}$. This is all in Lurie's *Higher Topos Theory*, but I recommend the exposition in Nikolaus, Schreiber and Stevenson's Principal $\infty$-bundles - General Theory.

Discrete groups are $0$-truncated objects in $\operatorname{Grp}(\mathcal{S})$, and the equivalence above implies an equivalence of mapping spaces:
$$
B : \operatorname{Map}_{\operatorname{Grp}(\mathcal{S})}(G, H) \to \operatorname{Map}_{\mathcal{S}^{\ast/}_{\geq 1}}(\mathbf{B}G, \mathbf{B}H)
$$
The left hand side here is homotopy equivalent to the set of group homomorphisms from $G$ to $H$, and taking $\pi_0$ gets you the desired bijection: $\hom(G, H) \cong [\mathbf{B}G, \mathbf{B}H]_0$.

If $H$ is not discrete, $\mathbf{B}H$ is no longer an Eilenberg-Maclane space: rather, $\pi_{i+1}(\mathbf{B}H, \ast) = \pi_i (H, e)$.

If what you really want is $K(H,1)$, you can give $H$ the discrete topology —call it $H^\delta$. Then you have $\mathbf{B}H^\delta \simeq K(H,1)$, and a bijection $$\hom(G, H) \cong \pi_0\operatorname{Map}_{\operatorname{Grp}(\mathcal{S})}(G, H^\delta) \cong [K(G, 1), K(H, 1)]_0$$ Forgetting the topology on $H$ is no big deal because $G$ is discrete.

For the classifying space $\mathbf{B}H$ things are more complicated. The most you (or at least I) can say is that there is a bijection $$\pi_0\operatorname{Map}_{\operatorname{Grp}(\mathcal{S})}(G, H) \cong [\mathbf{B}G, \mathbf{B}H]_0$$

As for your second question, the first group cohomology group with values in the 2-group associated to the crossed module $A \to C$ is given by the set of homotopy classes of (unbased) maps from $\mathbf{B}G$ to $\mathbf{B}(A \to C)$:
$$
H^1(G, A \to C) = [ \mathbf{B}G, \mathbf{B}(A \to C) ]
$$
(see the nLab pages on cohomology and group cohomology).