Do the following two CFGs describe the same language
No. The word &quot;abab&quot; is described by (1) but not (2). You can test and visualize this here.
Trying to think about it inductively: (1) can only prepend &quot;a&quot; or &quot;b&quot; to a string while (2) can only prepend &quot;a&quot; and only append &quot;b&quot;.
Switching the order of a production does not necessarily change the language the grammar represents, but it is in this case. As to the second part of your question, there is no generalizable or efficient way to determine whether two CFGs describe the same language.