Convex and Non-Convex Relaxations for Densest Subgraph and Submatrix Recovery: Theory and Applications in Community Detection and Drug-Target Prediction