The issue with queries 1 and 3 is that you have repeated deviceAttr.deviceId keys within the same object. JavaScript requires keys at the same level to be unique and will only use the last value set. Both of these queries are equivalent to:
Your query 4 example avoids the issue of repeated fields using the $and query operator, which is the correct approach for Queries With Multiple Expressions Specifying the Same Field in JavaScript. The result of matching all of the query conditions is a single document, which is expected as the combination of the previous queries.