Here's a version that can handle macros in the argument. For demonstration purposes, I make \backend perform a \detokenize on its argument, so that we can see exactly what tokens it receives. Note that, in the presented output, the space after \mymacro is a function of \detokenize and not of the \command macro.
As to the logic, the \readlist macro reads the comma separated list into an array \myarg. The * invocation of \readlist* discards empty space around each item in the list. Then, the \foreachitem loop goes through each item in sequence and I use \g@addto@maco to append the tokens of the item to \tmp, along with commas at the proper places. A once-expanded \tmp is finally passed to \backend.
The key point I will mention is that the original tokens are passed directly to \backend with this method. No further expansion of the argument is required by \backend to obtain the desired tokens. It is as if one typed the space-free argument list directly to \backend.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{listofitems}
\makeatletter
\newcommand\command[1]{%
\setsepchar{,}%
\readlist*\myarg{#1}%
\def\tmp{}%
\foreachitem\x\in\myarg{%
\ifnum\xcnt=1\relax\else\g@addto@macro\tmp{,}\fi%
\expandafter\g@addto@macro\expandafter\tmp\expandafter{\x}%
}%
\expandafter\backend\expandafter{\tmp}%
}
\makeatother
\newcommand\backend[1]{[\detokenize{#1}]}
\begin{document}
\command{a, b}
\command{a, b,c, \mymacro, dfdg}
\end{document}

Note that, with the above code, only spaces around commas are discarded...whereas spaces within an argument are preserved, so that \command{a a , bb b, c} is processed as \backend{a a,bb b,c}. That may be a non-issue for the OP, if all arguments contain no spaces by their nature. Or it may even be a desired feature.
On the other hand, if it is desired to remove all spaces, including intra-argument spaces, then the following code will suffice. Here, it uses the space, rather than the comma, as the item-separator in digesting the list. Then, when it regurgitates the list item-by-item, the separator (space) is not part of the regurgitated list item.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{listofitems}
\makeatletter
\newcommand\command[1]{%
\setsepchar{ }%
\readlist\myarg{#1}%
\def\tmp{}%
\foreachitem\x\in\myarg{%
\expandafter\g@addto@macro\expandafter\tmp\expandafter{\x}%
}%
\expandafter\backend\expandafter{\tmp}%
}
\makeatother
\newcommand\backend[1]{[\detokenize{#1}]}
\begin{document}
\command{a, b}
\command{a, b,c, \mymacro, df dg}
\end{document}
\commanddoes not include macros. – campa Jun 02 '17 at 09:15