In the first case, jQuery is passed directly and reassigned to use the local variable $ in the method. In the first case, $ will act like jQuery, as you are used to. This is often used for plugins that do not assume that $ represents jQuery (since jQuery may refuse to not use $ if there is a conflict).
In the second case, jQuery only does this conflict protection for you, providing you with a local view of $ that will not conflict with any other libraries.
The first is also called when it is analyzed, as mentioned by others. The leading parenthesis is a convention, implying that the function definition itself is followed by a set of open / clos parentheses, which runs immediately. The second is caused by page loading.
source share