This paper presents a novel approach to applying Self-Supervised Learning (SSL), a powerful representation learning method in computer vision, to dependent data such as time series and spatiotemporal data. To overcome the limitations of existing contrastive SSL methods, which assume semantic independence between samples, we propose a new theoretical framework for contrastive SSL for continuous dependent data. This framework allows for the closest samples to be semantically close and introduces two possible ground truth similarity measures: hard and soft proximity. Based on this, we derive an analytical form of the estimated similarity matrix that accommodates both types of proximity between samples and propose a dependency-aware loss function. The proposed methodology, "Dependent TS2Vec," is validated on time series and spatiotemporal problems, outperforming state-of-the-art methods for dependent data, demonstrating the effectiveness of this theoretically grounded loss function.