The moment you use a "static reference" to a feature, it becomes a dependency. In other words, your code depends upon Communities being enabled, and therefore the platform requires it to be enabled.
Code like the following automatically causes dependency:
Map<String, SObjectField> fieldMap = Schema.sobjectType.Network.fields.getMap();
Network[] records = [SELECT Name FROM Network];
Network record = new Network(Name='abc');
In order to avoid this, you will need to use "dynamic references", such as the following:
if(Schema.getGlobalDescribe().containsKey('Network')) {
sobject[] results = Database.query('select name from network');
for(sobject result: results) {
String name = (String)result.get('Name');
// ... etc ... //
}
}