Unlike the provided widget, the function pll_the_languages does not include the necessary javascript code to make the dropdown menu work. You can inspired yourself from the widget code in polylang/include/widget-languages.php to make it work.
Since you're not the first to ask, I made change this in the future.