What you have really done is two create two separate tables; even if these tables have the same keys and values, they are still distinct (and their keys can be set separately). Setting any key on a table does not change its reference. When you write 'a==b' you don't test if their content are equal, you just test if they are references to the same table: '==' is not a "deep" equality test. Remember that tables are used in Lua to act as "objects"; their content is exactly like an unordered set of properties, indexed by a unique key. Technically these objects do not even have a welldefined "length" (this is the main difference with arrays/vectors, that Lua represent as tables whose keys form a sequence, but sequences in Lua are not restricted to be just tables, they could be "generators" as well, accessed... sequentially with a well defined order of integer keys starting from 1 but possibility no end, where as a table in Lua can be accessed in random order on specific keys. Tables do not necessarily store their content in memory, because they can have a metatable containing accessor methods.
For this case, Lua behaves like other similar languages: _javascript_, Python, Postscript,
C#,
PHP,
...